home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 003-desktop.lzm / usr / bin / startkde < prev    next >
Encoding:
Text File  |  2007-11-07  |  14.0 KB  |  413 lines

  1. #!/bin/sh
  2. #
  3. #  DEFAULT KDE STARTUP SCRIPT ( KDE-3.5.8 )
  4. #
  5.  
  6. # When the X server dies we get a HUP signal from xinit. We must ignore it
  7. # because we still need to do some cleanup.
  8. trap 'echo GOT SIGHUP' HUP
  9.  
  10. # Check if a KDE session already is running
  11. if kcheckrunning >/dev/null 2>&1; then
  12.     echo "KDE seems to be already running on this display."
  13.     xmessage -geometry 500x100 "KDE seems to be already running on this display." > /dev/null 2>/dev/null
  14.     exit 1
  15. fi
  16.  
  17. # Set the background to plain grey.
  18. # The standard X background is nasty, causing moire effects and exploding
  19. # people's heads. We use colours from the standard KDE palette for those with
  20. # palettised displays.
  21. if test -z "$XDM_MANAGED" || echo "$XDM_MANAGED" | grep ",auto" > /dev/null; then
  22.   xsetroot -solid "#000000"
  23. fi
  24.  
  25. # we have to unset this for Darwin since it will screw up KDE's dynamic-loading
  26. unset DYLD_FORCE_FLAT_NAMESPACE
  27.  
  28. # in case we have been started with full pathname spec without being in PATH
  29. bindir=`echo "$0" | sed -n 's,^\(/.*\)/[^/][^/]*$,\1,p'`
  30. if [ -n "$bindir" ]; then
  31.   case $PATH in
  32.     $bindir|$bindir:*|*:$bindir|*:$bindir:*) ;;
  33.     *) PATH=$bindir:$PATH; export PATH;;
  34.   esac
  35. fi
  36.  
  37. # Boot sequence:
  38. #
  39. # kdeinit is used to fork off processes which improves memory usage
  40. # and startup time.
  41. #
  42. # * kdeinit starts the dcopserver and klauncher first.
  43. # * Then kded is started. kded is responsible for keeping the sycoca
  44. #   database up to date. When an up to date database is present it goes
  45. #   into the background and the startup continues.
  46. # * Then kdeinit starts kcminit. kcminit performs initialisation of
  47. #   certain devices according to the user's settings
  48. #
  49. # * Then ksmserver is started which takes control of the rest of the startup sequence
  50.  
  51. # The user's personal KDE directory is usually ~/.kde, but this setting
  52. # may be overridden by setting KDEHOME.
  53.  
  54. kdehome=$HOME/.kde
  55. test -n "$KDEHOME" && kdehome=`echo "$KDEHOME"|sed "s,^~/,$HOME/,"`
  56.  
  57. # see kstartupconfig source for usage
  58. mkdir -m 700 -p $kdehome
  59. mkdir -m 700 -p $kdehome/share
  60. mkdir -m 700 -p $kdehome/share/config
  61. cat >$kdehome/share/config/startupconfigkeys <<EOF
  62. kcminputrc Mouse cursorTheme ''
  63. kcminputrc Mouse cursorSize ''
  64. kpersonalizerrc General FirstLogin true
  65. ksplashrc KSplash Theme Default
  66. kcmrandrrc Display ApplyOnStartup false
  67. kcmrandrrc [Screen0]
  68. kcmrandrrc [Screen1]
  69. kcmrandrrc [Screen2]
  70. kcmrandrrc [Screen3]
  71. kcmfonts General forceFontDPI 0
  72. EOF
  73. kstartupconfig
  74. if test $? -ne 0; then
  75.     xmessage -geometry 500x100 "Could not start kstartupconfig. Check your installation."
  76. fi
  77. . $kdehome/share/config/startupconfig
  78.  
  79. # XCursor mouse theme needs to be applied here to work even for kded or ksmserver
  80. if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
  81.     kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
  82.     if test $? -eq 10; then
  83.         export XCURSOR_THEME=default
  84.     elif test -n "$kcminputrc_mouse_cursortheme"; then
  85.         export XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
  86.     fi
  87.     if test -n "$kcminputrc_mouse_cursorsize"; then
  88.         export XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
  89.     fi
  90. fi
  91.  
  92. if test "$kcmrandrrc_display_applyonstartup" = "true"; then
  93.     # 4 screens is hopefully enough
  94.     for scrn in 0 1 2 3; do
  95.         args=
  96.         width="\$kcmrandrrc_screen${scrn}_width" ; eval "width=$width"
  97.         height="\$kcmrandrrc_screen${scrn}_height" ; eval "height=$height"
  98.         if test -n "${width}" -a -n "${height}"; then
  99.             args="$args -s ${width}x${height}"
  100.         fi
  101.         refresh="\$kcmrandrrc_screen${scrn}_refresh" ; eval "refresh=$refresh"
  102.         if test -n "${refresh}"; then
  103.             args="$args -r ${refresh}"
  104.         fi
  105.         rotation="\$kcmrandrrc_screen${scrn}_rotation" ; eval "rotation=$rotation"
  106.         if test -n "${rotation}"; then
  107.             case "${rotation}" in
  108.                 0)
  109.                     args="$args -o 0"
  110.                     ;;
  111.                 90)
  112.                     args="$args -o 1"
  113.                     ;;
  114.                 180)
  115.                     args="$args -o 2"
  116.                     ;;
  117.                 270)
  118.                     args="$args -o 3"
  119.                     ;;
  120.             esac
  121.         fi
  122.         reflectx="\$kcmrandrrc_screen${scrn}_reflectx" ; eval "reflectx=$reflectx"
  123.         if test "${refrectx}" = "true"; then
  124.             args="$args -x"
  125.         fi
  126.         reflecty="\$kcmrandrrc_screen${scrn}_reflecty" ; eval "reflecty=$reflecty"
  127.         if test "${refrecty}" = "true"; then
  128.             args="$args -y"
  129.         fi
  130.         if test -n "$args"; then
  131.             xrandr $args
  132.         fi
  133.     done
  134. fi
  135.  
  136. dl=$DESKTOP_LOCKED
  137. unset DESKTOP_LOCKED # Don't want it in the environment
  138.  
  139. # Launch splash that doesn't need any KDE libraries here, before
  140. # KDE libraries are loaded into memory (which may take some time
  141. # with cold caches). Makes the splash appear sooner.
  142. # If kpersonalizer needs to be run splash will be started only later.
  143. if test -z "$dl" && test "$kpersonalizerrc_general_firstlogin" != "true"; then
  144.     case "$ksplashrc_ksplash_theme" in 
  145.       Simple)
  146.          ksplashsimple 
  147.          ;;
  148.       *)
  149.          ;;
  150.     esac
  151. fi
  152.  
  153. if test "$kcmfonts_general_forcefontdpi" -eq 120; then
  154.     xrdb -quiet -merge -nocpp <<EOF
  155. Xft.dpi: 120
  156. EOF
  157. elif test "$kcmfonts_general_forcefontdpi" -eq 96; then
  158.     xrdb -quiet -merge -nocpp <<EOF
  159. Xft.dpi: 96
  160. EOF
  161. fi
  162.  
  163. # Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
  164. # (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
  165. #
  166. # This is where you can define environment variables that will be available to
  167. # all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
  168. # or eval `gpg-agent --daemon`.
  169. # Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
  170. #
  171. # (see end of this file).
  172. # For anything else (that doesn't set env vars, or that needs a window manager),
  173. # better use the Autostart folder.
  174.  
  175. exepath=`kde-config --path exe | tr : '\n'`
  176.  
  177. for prefix in `echo "$exepath" | sed -n -e 's,/bin[^/]*/,/env/,p'`; do
  178.   for file in "$prefix"*.sh; do
  179.     test -r "$file" && . "$file"
  180.   done
  181. done
  182.  
  183. # Activate the kde font directories.
  184. #
  185. # There are 4 directories that may be used for supplying fonts for KDE.
  186. #
  187. # There are two system directories. These belong to the administrator.
  188. # There are two user directories, where the user may add her own fonts.
  189. #
  190. # The 'override' versions are for fonts that should come first in the list,
  191. # i.e. if you have a font in your 'override' directory, it will be used in
  192. # preference to any other.
  193. #
  194. # The preference order looks like this:
  195. # user override, system override, X, user, system
  196. #
  197. # Where X is the original font database that was set up before this script
  198. # runs.
  199.  
  200. usr_odir=$HOME/.fonts/kde-override
  201. usr_fdir=$HOME/.fonts
  202.  
  203. # Add any user-installed font directories to the X font path
  204. kde_fontpaths=$usr_fdir/fontpaths
  205. do_usr_fdir=1
  206. do_usr_odir=1
  207. if test -r "$kde_fontpaths" ; then
  208.     savifs=$IFS
  209.     IFS="
  210. "
  211.     for fpath in `grep -v '^[     ]*#' < "$kde_fontpaths"` ; do
  212.         rfpath=`echo $fpath | sed "s:^~:$HOME:g"`
  213.         if test -s "$rfpath"/fonts.dir; then
  214.             xset fp+ "$rfpath"
  215.             if test "$rfpath" = "$usr_fdir"; then
  216.                 do_usr_fdir=0
  217.             fi
  218.             if test "$rfpath" = "$usr_odir"; then
  219.                 do_usr_odir=0
  220.             fi
  221.         fi
  222.     done
  223.     IFS=$savifs
  224. fi
  225.  
  226. if test -n "$KDEDIRS"; then
  227.   kdedirs_first=`echo "$KDEDIRS"|sed -e 's/:.*//'`
  228.   sys_odir=$kdedirs_first/share/fonts/override
  229.   sys_fdir=$kdedirs_first/share/fonts
  230. else
  231.   sys_odir=$KDEDIR/share/fonts/override
  232.   sys_fdir=$KDEDIR/share/fonts
  233. fi
  234.  
  235. # We run mkfontdir on the user's font dirs (if we have permission) to pick
  236. # up any new fonts they may have installed. If mkfontdir fails, we still
  237. # add the user's dirs to the font path, as they might simply have been made
  238. # read-only by the administrator, for whatever reason.
  239.  
  240. # Only do usr_fdir and usr_odir if they are *not* listed in fontpaths
  241. test -d "$sys_odir" && xset +fp "$sys_odir"
  242. test $do_usr_odir -eq 1 && test -d "$usr_odir" && (mkfontdir "$usr_odir" ; xset +fp "$usr_odir")
  243. test $do_usr_fdir -eq 1 && test -d "$usr_fdir" && (mkfontdir "$usr_fdir" ; xset fp+ "$usr_fdir")
  244. test -d "$sys_fdir" && xset fp+ "$sys_fdir"
  245.  
  246. # Ask X11 to rebuild its font list.
  247. xset fp rehash
  248.  
  249. # Set a left cursor instead of the standard X11 "X" cursor, since I've heard
  250. # from some users that they're confused and don't know what to do. This is
  251. # especially necessary on slow machines, where starting KDE takes one or two
  252. # minutes until anything appears on the screen.
  253. #
  254. # If the user has overwritten fonts, the cursor font may be different now
  255. # so don't move this up.
  256. #
  257.  
  258. # TM: Set watch cursor instead of the default
  259. xsetroot -cursor_name watch
  260.  
  261. # TM: Set the background picture.
  262. qiv -o '#4670B5' -m -x /usr/share/wallpapers/slax-wallpaper.jpg
  263.  
  264. # TM: Configure and start LISA network browser
  265. /usr/bin/lisa 2>/dev/null
  266.  
  267. # Get Ghostscript to look into user's KDE fonts dir for additional Fontmap
  268. if test -n "$GS_LIB" ; then
  269.     GS_LIB=$usr_fdir:$GS_LIB
  270.     export GS_LIB
  271. else
  272.     GS_LIB=$usr_fdir
  273.     export GS_LIB
  274. fi
  275.  
  276. # Link "tmp" "socket" and "cache" resources to directory in /tmp
  277. # Creates:
  278. # - a directory /tmp/kde-$USER and links $KDEHOME/tmp-$HOSTNAME to it.
  279. # - a directory /tmp/ksocket-$USER and links $KDEHOME/socket-$HOSTNAME to it.
  280. # - a directory /var/tmp/kdecache-$USER and links $KDEHOME/cache-$HOSTNAME to it.
  281. # Note: temporary locations can be overriden through the KDETMP and KDEVARTMP
  282. # environment variables
  283. for resource in tmp cache socket; do
  284.     if ! lnusertemp $resource >/dev/null; then
  285.         echo 'startkde: Call to lnusertemp failed (temporary directories full?). Check your installation.'  1>&2
  286.         xmessage -geometry 600x100 "Call to lnusertemp failed (temporary directories full?). Check your installation."
  287.         exit 1
  288.     fi
  289. done
  290.  
  291. # In case of dcop sockets left by a previous session, cleanup
  292. dcopserver_shutdown
  293.  
  294. echo 'startkde: Starting up...'  1>&2
  295.  
  296. # run KPersonalizer before the session, if this is the first login
  297. if test "$kpersonalizerrc_general_firstlogin" = "true"; then
  298.     # start only dcopserver, don't start whole kdeinit (takes too long)
  299.     echo 'startkde: Running kpersonalizer...'  1>&2
  300.     dcopserver
  301.     kwin --lock &
  302.     kpersonalizer --before-session
  303.     # handle kpersonalizer restarts (language change)
  304.     while test $? -eq 1; do
  305.         kpersonalizer --r --before-session
  306.     done
  307.     dcopquit kwin
  308.     dcopserver_shutdown --wait
  309. fi
  310.  
  311. if test -z "$dl"; then
  312.   # the splashscreen and progress indicator
  313.   case "$ksplashrc_ksplash_theme" in 
  314.     None)
  315.        ;; # nothing
  316.     Simple)
  317.        if test "$kpersonalizerrc_general_firstlogin" = "true"; then
  318.            ksplashsimple 
  319.        fi # otherwise started earlier
  320.        ;;
  321.     *)
  322.        ksplash --nodcop
  323.        ;;
  324.   esac
  325. fi
  326.  
  327. # Mark that full KDE session is running (e.g. Konqueror preloading works only
  328. # with full KDE running). The KDE_FULL_SESSION property can be detected by
  329. # any X client connected to the same X session, even if not launched
  330. # directly from the KDE session but e.g. using "ssh -X", kdesu. $KDE_FULL_SESSION
  331. # however guarantees that the application is launched in the same environment
  332. # like the KDE session and that e.g. KDE utilities/libraries are available.
  333. # KDE_FULL_SESSION property is also only available since KDE 3.5.5.
  334. # The matching tests are:
  335. #   For $KDE_FULL_SESSION:
  336. #     if test -n "$KDE_FULL_SESSION"; then ... whatever
  337. #   For KDE_FULL_SESSION property:
  338. #     xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
  339. #     if test $? -eq 0; then ... whatever
  340. #
  341. # Additionally there is (since KDE 3.5.7) $KDE_SESSION_UID with the uid
  342. # of the user running the KDE session. It should be rarely needed (e.g.
  343. # after sudo to prevent desktop-wide functionality in the new user's kded).
  344. #
  345. KDE_FULL_SESSION=true
  346. export KDE_FULL_SESSION
  347. xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
  348. KDE_SESSION_UID=$UID
  349. export KDE_SESSION_UID
  350.  
  351. # We set LD_BIND_NOW to increase the efficiency of kdeinit.
  352. # kdeinit unsets this variable before loading applications.
  353. LD_BIND_NOW=true start_kdeinit_wrapper --new-startup +kcminit_startup
  354. if test $? -ne 0; then
  355.   # Startup error
  356.   echo 'startkde: Could not start kdeinit. Check your installation.'  1>&2
  357.   xmessage -geometry 500x100 "Could not start kdeinit. Check your installation."
  358. fi
  359.  
  360. # If the session should be locked from the start (locked autologin),
  361. # lock now and do the rest of the KDE startup underneath the locker.
  362. if test -n "$dl"; then
  363.   kwrapper kdesktop_lock --forcelock &
  364.   # Give it some time for starting up. This is somewhat unclean; some
  365.   # notification would be better.
  366.   sleep 1
  367. fi
  368.  
  369. # finally, give the session control to the session manager
  370. # see kdebase/ksmserver for the description of the rest of the startup sequence
  371. # if the KDEWM environment variable has been set, then it will be used as KDE's
  372. # window manager instead of kwin.
  373. # if KDEWM is not set, ksmserver will ensure kwin is started.
  374. # kwrapper is used to reduce startup time and memory usage
  375. # kwrapper does not return usefull error codes such as the exit code of ksmserver.
  376. # We only check for 255 which means that the ksmserver process could not be 
  377. # started, any problems thereafter, e.g. ksmserver failing to initialize, 
  378. # will remain undetected.
  379. test -n "$KDEWM" && KDEWM="--windowmanager $KDEWM"
  380. kwrapper ksmserver $KDEWM 
  381. if test $? -eq 255; then
  382.   # Startup error
  383.   echo 'startkde: Could not start ksmserver. Check your installation.'  1>&2
  384.   xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
  385. fi
  386.  
  387. # wait if there's any crashhandler shown
  388. while dcop | grep -q ^drkonqi- ; do
  389.     sleep 5
  390. done
  391.  
  392. echo 'startkde: Shutting down...'  1>&2
  393.  
  394. # Clean up
  395. kdeinit_shutdown
  396. dcopserver_shutdown --wait
  397. artsshell -q terminate
  398.  
  399. echo 'startkde: Running shutdown scripts...'  1>&2
  400.  
  401. # Run scripts found in $KDEDIRS/shutdown
  402. for prefix in `echo "$exepath" | sed -n -e 's,/bin[^/]*/,/shutdown/,p'`; do
  403.   for file in `ls "$prefix" 2> /dev/null | egrep -v '(~|\.bak)$'`; do
  404.     test -x "$prefix$file" && "$prefix$file"
  405.   done
  406. done
  407.  
  408. unset KDE_FULL_SESSION
  409. xprop -root -remove KDE_FULL_SESSION
  410. unset KDE_SESSION_UID
  411.  
  412. echo 'startkde: Done.'  1>&2
  413.